﻿using Android.Database.Sqlite;
using Android.Content;

namespace CapstoneProject.DataAccess
{
    public class UserDatabaseHelper : SQLiteOpenHelper
    {
        private const string DATABASE_NAME = "CapstoneDB";
        private const int DATABASE_VERSION = 1;

        public UserDatabaseHelper(Context context)
            : base(context, DATABASE_NAME, null, DATABASE_VERSION)
        {
        }

        public override void OnCreate(SQLiteDatabase db)
        {
            db.ExecSQL(@"CREATE TABLE User(UserId INTEGER PRIMARY KEY AUTOINCREMENT, 
                                            Username TEXT NOT NULL, 
                                            Password TEXT NOT NULL
            )");
        }

        public override void OnUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
        {
            db.ExecSQL("DROP TABLE IF EXISTS User");

            OnCreate(db);
        }
    }
}
